// 平滑曲线
<template>
  <div>
    <div class="threeBarChart" id="smoothLine"></div>
  </div>

</template>

<script>
export default {
  name: '',
  data() {
    return {}
  },
  computed: {
    reset() {
      return this.$store.getters.sidebar.opened
    }
  },
  props: {
    xline: Array, // x轴名称列表
    yline: Array, // y轴数据
    config: Object // 参数配置
  },

  methods: {
    // 重新绘制图表
    forceRerender() {

    },
    setChart() {
      this.myChart = this.$echarts.init(document.getElementById('smoothLine'))
      this.myChart.clear();
      this.myChart.resize()
      this.myChart.setOption(this.option);
    },
    setDataAndRedraw(data) {
      var option1 = JSON.parse(JSON.stringify(this.option))
      option1.series[0].data = data
      console.log("reset data:")
      console.log(option1.series.data)
      if (!this.myChart) {
        this.myChart = this.$echarts.init(document.getElementById('smoothLine'))
      }
      this.myChart.clear();
      this.myChart.resize();
      this.myChart.setOption(option1);
    },

  },
  data() {
    return {
      myChart: undefined,
      option: {
        xAxis: {
          type: 'category',
          data: ['原材料', '生产阶段', '分销阶段', '使用阶段', '废弃处置'],
          style: {}
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: [200, 1200, 1400, 1500, 1800],
            type: 'line',
            smooth: true
          }
        ]
      },
      optionList: [],
      option1: {}
    }
  },
  mounted() {
    this.setChart()
  },
  watch: {}
}
</script>

<style lang="less" scoped>
.threeBarChart {
  height: 400px;
  width: 670px;
}
</style>
